Avorion Script API Documentation

Player Callbacks

Note: Callbacks have to be buffered in certain situations and won't happen immediately. When unregistering a callback during a callback, all callbacks that were buffered during the last frame may still be sent, even though they were unregistered.

callback onAllianceChanged(allianceIndex)

Executed whenever the player's alliance changes

Parameters

allianceIndex The faction index of the alliance

callback onAllianceInvitationReceived(allianceIndex)

Executed whenever the player receives an invitation from an alliance

Parameters

allianceIndex The faction index of the alliance

callback onAllScriptValuesChanged(playerIndex)

Executed whenever all scripts values of the player have been changed at once

Parameters

playerIndex The index of the player

callback onChatMessage(playerIndex, text, channel)

Executed whenever the player sent a chat message to the server. Only called if the chat message is valid and the player doesn't have a chat ban.

Parameters

playerIndex Index of the player
text The text content of the chat message
channel The channel the message was sent to. 0 = All, 1 = Sector, 2 = Group, 3 = Alliance

callback onChatRestrictionTimeChanged(time)

Executed whenever a player's chat restriction time is changed. This usually only happens when administrators need to stop a player from using chat.

Parameters

time The time that player is muted

callback onCraftChanged(id, previousId)

Called whenever the player changes their flown craft

Parameters

id The id of the new craft
previousId The id of the previous craft

callback onGalaxyMapKeyboardUp(button)

Executed whenever a keyboard-up event occurs on the galaxy map. Keyboad-Up events are transferred to all UI elements and can't be consumed.

Parameters

button The scancode of the button that was pressed

callback onGalaxyMapMouseUp(button, mx, my, cx, cy, mapMoved)

Executed whenever a mouse-up event occurs on the galaxy map. Mouse-Up events are transferred to all UI elements and can't be consumed.

Parameters

button The button that was released
mx The mouse X position
my The mouse Y position
cx The coordinates X position
cy The coordinates Y position
mapMoved True if the map was moved during the mouse pressing

callback onGroupChanged(groupIndex)

Executed whenever the player's group index changes

Parameters

groupIndex The index of the group the player is in

callback onGroupLeaderChanged(playerIndex)

Executed whenever the leader of the player's group changes

Parameters

playerIndex The index of the new leader player

callback onGroupPlayerCraftChanged(playerIndex, id)

Executed whenever another player of the player's group changes crafts

Parameters

playerIndex The index of the other player
id The id of the new craft

callback onGroupPlayerSectorChanged(playerIndex, x, y)

Executed whenever another player of the player's group changes sectors

Parameters

playerIndex The index of the other player
x The x coordinate of the new sector
y The y coordinate of the new sector

callback onHomeSectorChanged(x, y)

Called whenever the home sector of the player changes

Parameters

x The x coordinate of the new home sector
y The y coordinate of the new home sector

callback onHyperspaceRestrictionTimeChanged(time)

Executed whenever a player's hyperspace restriction time is changed. This usually only happens when administrators need to trap a player in a specific sector.

Parameters

time The time that player is trapped

callback onItemAdded(itemIndex, amount, amountBefore)

Executed whenever the number of items in a particular item slot in the player's inventory increases or a new item was added.

Parameters

itemIndex Index of the item
amount The new amount of this item
amountBefore The amount of this item before the change

callback onItemChanged(itemIndex, amount, amountBefore)

Executed whenever the number of items in a particular item slot in the player's inventory changes.

Parameters

itemIndex Index of the item
amount The new amount of this item
amountBefore The amount of this item before the change

callback onItemPropertiesChanged(item, index, amount)

Called whenever an item in the player inventory changes properties

Parameters

item The inventory item
index Index of the inventory item
amount Amount of items in the slot

callback onItemRemoved(itemIndex, amount, amountBefore)

Executed whenever the number of items in a particular item slot in the player's inventory decreases or the item was removed.

Parameters

itemIndex Index of the item
amount The new amount of this item
amountBefore The amount of this item before the change

callback onJumpRouteCalculationStarted(playerIndex, craftIndex, destinationX, destinationY)

Executed whenever a player starts a new hyperspace jump route calculation

Parameters

playerIndex The index of the player starting the calculation
craftIndex The id of the entity that does the calculation
destinationX The x-coordinate of the destination sector
destinationY The y-coordinate of the destination sector

callback onKnownSectorAdded(x, y)

Called whenever a new tracked sector is added to the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onKnownSectorRemoved(x, y)

Called whenever a tracked sector was removed from the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onKnownSectorUpdated(x, y)

Called whenever a tracked sector is updated in the player database

Parameters

x The x coordinate of the sector
y The y coordinate of the sector

callback onMailAdded(playerIndex, mail, mailIndex)

Executed whenever the player receives a new mail

Parameters

playerIndex Index of the player
mail The received mail
mailIndex Index of the received mail

callback onMailCleared(playerIndex, mailIndex)

Executed whenever the player takes the contents of a mail

Parameters

playerIndex Index of the player
mailIndex Index of the cleared mail

callback onMailDeleted(playerIndex, mailIndex)

Executed whenever the player deletes a mail

Parameters

playerIndex Index of the player
mailIndex Index of the deleted mail

callback onMailRead(playerIndex, mailIndex)

Executed whenever the player reads a mail

Parameters

playerIndex Index of the player
mailIndex Index of the read mail

callback onMaxBuildableMaterialChanged(material)

Executed whenever a player's ship building knowledge changes.

Parameters

material The material up to which the player can now build blocks

callback onMaxBuildableSocketsChanged(slots)

Executed whenever a player's ship building knowledge changes.

Parameters

slots The maximum amount of slots the player can now build

callback onMoveToReconstructionSite(x, y, playerIndex)

Executed whenever a move to reconstruction or respawn site is triggered because the player was destroyed. Called even if the player is already at their reconstruction/respawn site. Coordinates can be either reconstruction site or respawn site.

Parameters

x X coordinate of destination the player is moved to
y Y coordinate of destination the player is moved to
playerIndex Index of the player

callback onPlayerArrivalConfirmed(playerIndex)

Executed when the client reports that it entered the target sector. Clients send a message to the server once the loading screen ended. Once you receive this callback, the client has successfully loaded the sector it went into.

Parameters

playerIndex Index of the player

callback onPlayerEnteredGroup(playerIndex)

Executed whenever another player enters the player's group

Parameters

playerIndex The index of the player who entered

callback onPlayerLeftGroup(playerIndex)

Executed whenever another player from the player's group leaves the group

Parameters

playerIndex The index of the player who left

callback onReconstructionSectorChanged(x, y)

Executed whenever the player's respawn sector changes

Parameters

x The x coordinate of the new sector
y The y coordinate of the new sector

callback onRelationChanged(index, level, levelBefore, notify)

Called whenever relations of the player to another faction change

Parameters

index The index of the other faction
level The level of the relation
levelBefore The level of the relation before the change
notify A boolean indicating whether or not the player should be notified about the change

callback onRelationLevelChanged(playerIndex, factionIndex, relations)

Executed whenever the relations of the player to another faction changes.

Parameters

playerIndex Index of the player
factionIndex Index of the other faction
relations The new relations of the player to the other faction

callback onRelationStatusChanged(playerIndex, factionIndex, status)

Executed whenever the relation status of the player to another faction changes.

Parameters

playerIndex Index of the player
factionIndex Index of the other faction
status The new relation status of the player to the other faction

callback onResourcesChanged(playerIndex)

Executed whenever the money or resources of the player change

Parameters

playerIndex Index of the player

callback onScriptAdded(playerIndex, scriptIndex, scriptPath)

Executed after a script was added to the player

Parameters

playerIndex The index of the player
scriptIndex The index of the script that was added
scriptPath The path of the old script

callback onScriptRemoved(playerIndex, oldScriptIndex, scriptPath)

Executed after a script was removed from the player

Parameters

playerIndex The index of the player
oldScriptIndex The old index of the script that was removed
scriptPath The path of the old script

callback onScriptValueChanged(playerIndex, name, value)

Executed whenever a script value of the player was changed

Parameters

playerIndex The index of the player
name The name of the value
value The new value

callback onSectorArrivalConfirmed(playerIndex, x, y)

Executed when the client reports that it entered the target sector. Clients send a message to the server once the loading screen ended. Once you receive this callback, the client has successfully loaded the sector it went into.

Parameters

playerIndex Index of the player
x X-Coordinate of the entered sector
y Y-Coordinate of the entered sector

callback onSectorChanged(x, y)

Executed whenever the player changes the sector. Specifically, this callback is sent whenever the player's sector coordinates change in the database, even when they're not online.

Parameters

x The x coordinate of the new sector
y The y coordinate of the new sector

callback onSectorEntered(playerIndex, x, y, sectorChangeType)

Executed whenever the player is logged in and physically enters a new sector.

Parameters

playerIndex Index of the player
x The x coordinates of the sector entered
y The y coordinates of the sector entered
sectorChangeType The kind of sector change that is happening

callback onSectorLeft(playerIndex, x, y, sectorChangeType)

Executed whenever the player leaves their current sector, before entities are removed

Parameters

playerIndex Index of the player
x The x coordinates of the sector left
y The y coordinates of the sector left
sectorChangeType The kind of sector change that is happening

callback onShipAvailabilityUpdated(name, availability)

Called whenever a ShipInfo changes availability status (ie. goes into background simulation)

Parameters

name The name of the ship
availability The new availability status of the ship

callback onShipCargoUpdated(name)

Called whenever the cargo of a ShipInfo changes

Parameters

name The name of the ship

callback onShipChanged(playerIndex, craftId)

Executed whenever the player changes the ship he is currently flying

Parameters

playerIndex Index of the player
craftId The id of the new craft he is flying

callback onShipCrewUpdated(name)

Called whenever the crew of a ShipInfo changes

Parameters

name The name of the ship

callback onShipHyperspacePropertiesUpdated(name, reach, canPassRifts)

Called whenever the hyperspace reach of a ShipInfo changes

Parameters

name The name of the ship
reach The new reach of the ship
canPassRifts A boolean indicating whether the ship can jump across rifts

callback onShipIconUpdated(name, icon)

Called whenever the icon of a ShipInfo changes

Parameters

name The name of the ship
icon The new icon of the ship

callback onShipInfoAdded(name)

Called whenever a ShipInfo is added to the player

Parameters

name The name of the new ship

callback onShipInfoRemoved(name)

Called whenever a ShipInfo is removed from the player

Parameters

name The name of the ship

callback onShipInfoUpdated(name)

Called whenever a ShipInfo is updated in some way

Parameters

name The name of the ship

callback onShipNameUpdated(name, newName)

Called whenever the name of a ShipInfo changes

Parameters

name The name of the ship
newName The new name of the ship

callback onShipOrderInfoUpdated(name, orderInfo)

Called whenever the order info of a ShipInfo changes

Parameters

name The name of the ship
orderInfo The order info of the ship

callback onShipPayDayUpdated(name, time)

Called whenever the payday of a ShipInfo changes

Parameters

name The name of the ship
time The payday of the ship

callback onShipPlanUpdated(name)

Called whenever the plan of a ShipInfo changes

Parameters

name The name of the ship

callback onShipPositionUpdated(name, x, y)

Called whenever a ShipInfo changes sectors

Parameters

name The name of the ship
x The new x coordinate of the ship
y The new y coordinate of the ship

callback onShipReconstructionValueUpdated(name, value)

Called whenever the reconstruction value of a ShipInfo changes

Parameters

name The name of the ship
value The value of the ship

callback onShipStatusMessageUpdated(name, status, args)

Called whenever the status info of a ShipInfo changes

Parameters

name The name of the ship
status The status info text of the ship
args A table holding the status info localization arguments

callback onShipTitleUpdated(name)

Called whenever the title of a ShipInfo changes

Parameters

name The name of the ship

callback onShipTypeUpdated(name, type)

Called whenever the entity type of a ShipInfo changes

Parameters

name The name of the ship
type The new entity type of the ship

Overview
Home Functions Search
Search:

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.7 c8e4beec84f7